/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package homeworkDemo04;

/**2010404102 覃忠姬
 *
 * @author Administrator
 */
public class chinaID {
    public static void main(String[] args) {
        String passport="45042219910113082x";
        boolean flag=true;
        if(passport.length()!=18){
            flag=false;
        }
        if(!(passport.endsWith("x")||passport.endsWith("0")||passport.endsWith("1")||passport.endsWith("2")||passport.endsWith("3")||passport.endsWith("4")||passport.endsWith("5")||passport.endsWith("6")||passport.endsWith("7")||passport.endsWith("8")||passport.endsWith("9"))){
        flag=false;
    }
   String numstr="0123456789";
   for(int i=0;i<passport.length();i++){
       char a=passport.charAt(i);
       int temp=numstr.indexOf(a);
       if(temp<0){
           flag=false;
           break;
       }
       if(flag)
       {
            System.out.println(" 是合法的身份证号码");
       }
       else
               {
                 System.out.println("不是合法的身份证号码");   
               }
       
   }

}
}
